//
//  ViewController.m
//  24-加密
//
//  Created by 曹曹 on 16/8/16.
//  Copyright © 2016年 曹曹. All rights reserved.
//

#import "ViewController.h"
#import "NSString+GX_MD5.h"
#import "NSString+GX_SHA_1.h"
#import "NSString+GX_Base64.h"
#import "NSString+GX_DES.h"

@interface ViewController ()

@end

@implementation ViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // MD5 SHA-1 单向散列函数(算法)
#pragma mark - 1.MD5 
    // 验证算法, 一般应用验证密码(单向散列函数)
    NSString *string = @"Hello, Moto!";
    NSString *finalMD5Losercase = [string MD5String32BitsLowercase];
    NSLog(@"finalMD5Losercase:%@", finalMD5Losercase);
    NSString *finalMD5Uppercase = [string MD5String32BitsUppercase];
    NSLog(@"finalMD5Uppercase:%@", finalMD5Uppercase);
    NSString *newMD5Lowercase = [string MD5String16BitsLowercase];
    NSLog(@"  newMD5Lowercase:        %@", newMD5Lowercase);
    NSString *newMD5Uppercase = [string MD5String16BitsUppercase];
    NSLog(@"  newMD5Uppercase:        %@", newMD5Uppercase);
#pragma mark - 2.SHA-1
    NSString *SHA_1String = [string SHA_1String];
    NSLog(@"      SHA_1String:%@", SHA_1String);
#pragma mark - 3.Base64
    NSString *base64String = [string base64String];
    NSLog(@"     base64String:%@", base64String);
    NSString *originString = [base64String stringForBase64];
    NSLog(@"     originString:%@", originString);
    //http://c.m.163.com/search/comp/MA%3D%3D/%@.html	网易搜索栏,将关键字转化成Base64, 拼接到%@位置, 可以获取数据 例如: 将"汽车"通过转化得到"5rG96L2m", 可以获取相应数据
    //https://github.com/reejosamuel/RSA
#pragma mark - 4.对称密码
    // 三种算法 DES 三重DES AES
    NSString *DESString = [string DESString];
    NSLog(@"        DESString:%@", DESString);
    NSString *originDESString = [DESString stringForDES];
    NSLog(@"  originDESString:%@", originDESString);
#pragma mark - 5.非对称密码
    // RSA
}


- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}


@end
